<template>
  <Table
    :row-class-name="rowclassname"
    :loading="loading"
    stripe
    :columns="columns1"
    :data="data1"
    height="420"
  ></Table>
</template>

<script>
export default {
  props: {
    datas: Array,
  },
  data() {
    return {
      loading: true,
      columns1: [
        {
          title: "作物ID",
          key: "zid",
        },
        {
          title: "作物名称",
          key: "zname",
        },
        {
          title: "单作物总库存量",
          key: "cropsum",
        },
        {
          title: "安全库存",
          key: "av",
        },
      ],
      data1: [],
    };
  },
  watch: {
    datas: {
      handler: function (nd) {
        this.data1 = nd;
        this.loading = false;
      },
    },
  },
  methods: {
    rowclassname(value) {
      if (value.cropsum) {
        if (value.cropsum <= value.av) {
          return "demo-table-error-row";
        }
      } else {
        // console.log("mhkdhkl")
        // return "";
      }
      return "";
    },
  },
};
</script>

<style>
.ivu-table .demo-table-error-row td {
  /* background-color: #ff6600; */
  color:  #ff6600;
}
</style>
